<?php
// +----------------------------------------------------------------------
// | FastXCMS [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.fastxcms.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\HomeBaseController;
use app\portal\model\PortalTagModel;

// 模块参数列表程序安装
global $configinfo;
$configinfo['listmodule'] = 1;
$configinfo['tagmodule'] = 1;

class TagController extends HomeBaseController
{
    public function index()
    {
		global $configblock,$configinfo,$configindex,$configbase,$configlang;

        $tid             = $this->request->param('tid');
		
		// 【模块参数程序安装】文章列表条件配置模块
		$configmodule="list";include_once(MODULEPARA_PATH.'/configmodule/configmodule/configmodulewhere.php');

        $portalTagModel = new PortalTagModel();
		// 新增自定义模块独立表配置 DATE:2020-3-27 START
		$moduletagtable = getmoduletagtable($configinfo['moduleid']);
		$moduletagtable = delthstr($moduletagtable,"fastxcms_","");
		$portalTagModel->name($moduletagtable);
		// 新增自定义模块独立表配置 DATE:2020-3-27 END

        if(is_numeric($tid)){
            $tag = $portalTagModel->where('id', $tid)->where('status', 1)->find();
        }else{
            $tag = $portalTagModel->where('name', $tid)->where('status', 1)->find();
        }


        if (empty($tag)) {
            abort(404, $configlang['noemptytag']);
        }

        $this->assign('tag', $tag);
		
		// 页页标题，关键词，描述
		$hometag = "[标签]";
		$seo_title = $configbase['seoconfig']['tagtitle'];
		$seo_keywords = $configbase['seoconfig']['tagkeyword'];
		$seo_description = $configbase['seoconfig']['tagdescription'];
		$seotag = seoheadtag($seo_title,$seo_keywords,$seo_description,$hometag,$tag['name']);
		$seotitle = $tag['name'];
		if($seotag['title'])$seotitle .= "-".$seotag['title'];
		$headmeta = seoheadmeta($seotitle,$seotag['keyword'],$seotag['description'],$configbase['config']['name']);
		$this->assign('headmeta', $headmeta);

		// 【模块参数程序安装】文章列表配置模块
		$configmodule="list";include_once(MODULEPARA_PATH.'/configmodule/configmodule/configmodule.php');

        return $this->fetch('/tag');
    }

}
